package org.example.web;

import jakarta.annotation.Resource;
import org.example.dto.OrderRequest;
import org.example.dto.ResultDto;
import org.example.service.OrderService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @Resource OrderService orderService;
    @PostMapping("/api/order")
    @ResponseStatus(HttpStatus.CREATED)
    public ResultDto<String> create(@RequestBody OrderRequest orderRequest){
        return ResultDto.<String>builder()
                .code("ok")
                .data(orderService.create(orderRequest))
                .build();
    }
}
